<template>
  <div class="main">
      <div>
          <!-- 二级路由插座 -->
            <router-view></router-view>
      </div>
    <!-- 底部导航栏 选中标签颜色active-color 未选中标签颜色inactive-color-->
    <van-tabbar v-model="activeTabbarIndex" active-color="#8B5729" inactive-color="#656565" route>
      <van-tabbar-item v-for="(item,index) in tabbarData" :key="index" :to="item.to">
        <span>{{item.title}}</span>
        <template #icon="props">
          <!--props插槽名称 active插槽自带属性 -->
          <img :src="props.active ? item.activeIcon : item.InactiveIcon" />
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  name:'Main',
  data() {
    return {
      activeTabbarIndex: 0,
      tabbarData: [
        {
          title: "首页",
          activeIcon: require('../assets/images/home_active.png'),
          InactiveIcon: require('../assets/images/home.png'),
          //跳转的路由
          to: { name: "Home" },
        },
        {
          title: "菜单",
          activeIcon: require('../assets/images/menu_active.png'),
          InactiveIcon: require('../assets/images/menu.png'),
          to: { name: "Menu" },
        },
        {
          title: "购物袋",
          activeIcon: require('../assets/images/shopbag_active.png'),
          InactiveIcon: require('../assets/images/shopbag.png'),
          to: { name: "Shopbag" },
        },
        {
          title: "订单",
          activeIcon: require('../assets/images/order_active.png'),
          InactiveIcon: require('../assets/images/order.png'),
          to: { name: "Order" },
        },
        {
          title: "我的",
          activeIcon:require('../assets/images/my_active.png'),
          InactiveIcon: require('../assets/images/my.png'),
          to: { name: "My" },
        }
      ]
    };
  },
  
};
</script>
<style lang="less" scoped>

</style>